package com.example.viewdemo;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.app.WindowDecorActionBar;
import android.util.Log;

public class MainActivity extends AppCompatActivity {
    private static final String TAG ="MainActivity" ;
    private DragView dv;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        dv= (DragView) findViewById(R.id.dv);
    }

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);
        //之所以不在oncreate是因为绘制还没开始，得到结果为0.
        int width=dv.getWidth();
        int height=dv.getHeight();
        Log.e(TAG,"宽度是："+width);
        dv.setWidthAndHei(width,height);
    }
}
